<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-orientation" content="portrait">
    <title>收入结算</title>
    <link rel="stylesheet" href="../../styles/h5/reset.min.css"/>
    <link rel="stylesheet" href="../../styles/h5/bank.css"/>
    <link rel="stylesheet" href="../../styles/h5/errortankuang.css"/>
    <!--以上为公共css样式-->
    <link rel="stylesheet" href="../../styles/h5/index.css"/>

    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery-1.9.1.min.js"></script>
    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery.modal.js"></script>
    <!--以上为公共js文件-->
</head>
<body>
<div class="zz-today">
    <span>今日待结算总额</span>
    <p class="zz-amt" id="zz-amt">￥</p>
    <a class="zz-promote-jj" id="zz-promote-jj" href="javascript:;">提升收益</a>
</div>
<div class="zz-header">结算查询</div>
<div class="zz-list">
    <ul>
        <li>
            <a class="zz-normal-settlement" href="javascript:;">
                <span class="zz-bank">正常结算明细</span>
                <span class="zz-right-arrow"></span>
            </a>
        </li>
        <li class="zz-settlement-detail">
            <a class="zz-advance-settlement" href="javascript:;">
                <span class="zz-bank">提前结算明细</span>
                <span class="zz-right-arrow"></span>
            </a>
        </li>
        <li>
            <a class="zz-change-bank" href="../../html/h5/changeCard.html">
                <span class="zz-bank">结算银行</span>
                <span class="zz-right-arrow"></span>
                <span class="zz-replace"></span>
                <span class="zz-income-bank-name"></span>
                <span class="zz-bank-icon zz-bank-icon-flr"></span>
            </a>
        </li>
    </ul>
</div>

<div class="zz-illustrate">
    <span>
        结算查询为扣除手续费后的汇总金额，如需了解详情可查看账单明细或前往月账单页面下载对账邮件。
    </span>
</div>

<!-- <input class="footer" type="button" style="display:none" value="提前结算"/> -->
</body>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/utils.js"></script>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/index.js"></script>
<script charset="utf-8" type="text/javascript">
    var $amt = $("#zz-amt");
    var $normal_settlement = $(".zz-normal-settlement");
    var $settlement_detail = $(".zz-settlement-detail");
    var $change_bank = $(".zz-change-bank");
    var $advance_settlement = $(".zz-advance-settlement");
    var $promote = $("#zz-promote-jj");
    var ktState = '';
    var merId = '';
    
    //$change_bank.attr("href", "../../html/h5/changeCard.html");
    $footer.css("display", "none");
    //待结算总额接口
    $.ajax({
        url: utils.ajaxUrl()+"h5/settleAmountController/queryAmount",
        async: false,
        type: 'get',
        success: function (res) {
        	var res = JSON.parse(res);
            //console.log(res);
            if (res && res.retCode == '0000') {
            	ktState = res.ktState;
            	merId = res.merId;
                $amt.html("￥" + res.balance);
                $normal_settlement.attr("href", "../../html/h5/payDetail.html?merId="+merId);
                
                $footer.css("display", "none");
                if (res.type == 0) {//type  0小微商户没有提前结算权限
                    $settlement_detail.css("display", "none");
                    $footer.css("display", "none");
                    return
                }
                
                if(ktState==0){
                	$settlement_detail.css("display", "none");
                }
                
                $advance_settlement.attr("href", "../../html/h5/advancePayDetail.html?merId="+merId);

            } else {
                utils.newModalPrompt(res.retMsg);
//                $footer.attr("disabled","true");
                $settlement_detail.css("display", "none");
                $footer.css("display", "none");
                $normal_settlement.attr("href", "javascript:;");
                $change_bank.attr("href", "javascript:;");
                $(".zz-bank-icon").css("background","none");
            }
        },
        error:function (){
        	utils.newModalPrompt("网络异常");
    	}
    });

    //绑卡信息接口
    $.ajax({
        url: utils.ajaxUrl()+"h5/settlementController/queryEdrewInfByMerId",
        async: false,
        type: 'get',
        success: function (res) {
            var res = JSON.parse(res);
            //console.log(res);
            if (res && res.retCode == '0000') {
                var data = res["EdrawInfReData"];
                $(".zz-income-bank-name").html(data.bankName);
                $(".zz-bank-icon").addClass(data.binBankId);
                $(".zz-replace").html("(" + utils.cutOut(data.bankAccount) + ")");
            } else {
                utils.newModalPrompt(res.retMsg);
                $(".zz-bank-icon").css("background","none");
                $footer.attr("disabled","true");
                //$settlement_detail.css("display", "none");
                $advance_settlement.attr("href", "javascript:;");
                //$footer.css("display", "none");
                $normal_settlement.attr("href", "javascript:;");
                $change_bank.attr("href", "javascript:;");
            }
        },
        error:function (){
        	utils.newModalPrompt("网络异常");
    	}
    });
    
    $.ajax({
        url: utils.ajaxUrl()+"h5/oAuchController/accountQuery",
        async: false,
        type: 'get',
        success: function (res) {
            //var res = JSON.parse(res);
            console.log(res);
            if (res && res.retCode == '0000') {
            	if(res.accountType ==2){//2无权限
            		$amt.css("padding-top",".4rem");
                 	$promote.hide();
             	}
             	if(res.accountType ==1){//未开通
                 	$promote.attr("href","../../html/h5/fundNotOpen.html");
             	}
             	if(res.accountType == 3 ||res.accountType == 4){
             	 	$promote.attr("href","../../html/h5/fundOpenAccount.html");
             	}
            } else {
            	$promote.hide();
            	$amt.css("padding-top",".4rem");
                utils.newModalPrompt(res.retMsg);
            }
        },
        error:function (){
        	$promote.hide();
        	$amt.css("padding-top",".4rem");
            utils.newModalPrompt("数据异常");
        }
    });

    $footer.click(function () {
        if (ktState == 0) {
            window.location.href = "../../html/h5/advanceSettleOpen.html?merId=" + merId;
        } else {
            window.location.href = "../../html/h5/advancePayApply.html?merId=" + merId;
        }
    })

</script>
</html>